
//
//  LJHPlayerView.m
//  HEARME
//
//  Created by mac on 16/1/27.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LJHPlayerView.h"

@implementation LJHPlayerView


////音乐播放页面上的子视图
////背景图片
//@property(nonatomic,retain)UIImageView *backgroundImageView;
////返回按钮
//@property(nonatomic,retain)UIButton *backButton;
////标题
//@property(nonatomic,retain)UILabel *titleLabel;
////播放过得
//@property(nonatomic,retain)UILabel *playCount;
////定时按钮
//@property(nonatomic,retain)UIButton *clockButton;
////图片
//@property(nonatomic,retain)UIImageView *musicImageView;
////播放列表按钮
//@property(nonatomic,retain)UIButton *listButton;
////播放列表标签
//@property(nonatomic,retain)UILabel *listLabel;
////播放历史按钮
//@property(nonatomic,retain)UIButton *historyButton;
////播放历史标签
//@property(nonatomic,retain)UILabel *historyLabel;
////上一首按钮
//@property(nonatomic,retain)UIButton *upButton;
////下一首按钮
//@property(nonatomic,retain)UIButton *nextButton;
////播放按钮
//@property(nonatomic,retain)UIButton *playButton;
////进度条
//@property(nonatomic,retain)UISlider *slider;
////进度条
//@property(nonatomic,retain)UISlider *progressSlider;

//- (void)dealloc
//{
//    [_timeLabel release];
//    [_playButton release];
//    [_musicImageView release];
//    [_listButton release];
//    [_nextButton release];
//    [_slider release];
//    [_progressSlider release];
//    [_historyButton release];
//    [_upButton release];
//    [_backgroundImageView release];
//    
//    [super dealloc];
//}


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createSubviews];
    }
    
    return self;
}

-(void)createSubviews
{
    self.backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, WIDTH*1.28)];
    self.backgroundImageView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.backgroundImageView];
    [_backgroundImageView release];
    
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    
    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
    
    [visualEffectView setFrame:self.backgroundImageView.bounds];
    
    [self.backgroundImageView addSubview:visualEffectView];
    [visualEffectView release];
    
    
    
    
    //音乐图片
    self.musicImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*0.1, WIDTH*0.25, WIDTH*0.8, WIDTH*0.8)];
    self.musicImageView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.musicImageView];
    [_musicImageView release];
    
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH*0.7/2, self.musicImageView.frame.origin.y+self.musicImageView.frame.size.height+WIDTH*0.15, WIDTH*0.3, 20)];
    self.timeLabel.backgroundColor = [UIColor clearColor];
    self.timeLabel.text = @"00:00 / 00:00";
    self.timeLabel.font = [UIFont systemFontOfSize:13 weight:1];
    self.timeLabel.textColor = [UIColor whiteColor];
    [self addSubview:self.timeLabel];
    [_timeLabel release];
    
    
    //进度条
    self.progressSlider = [[UISlider alloc] initWithFrame:CGRectMake(0, self.timeLabel.frame.origin.y+self.timeLabel.frame.size.height+WIDTH*0.02, WIDTH, 5)];
    self.progressSlider.backgroundColor = [UIColor clearColor];
    [self addSubview:self.progressSlider];
    [_progressSlider release];
    self.progressSlider.minimumTrackTintColor = [UIColor colorWithRed:0.98 green:0.35 blue:0.16 alpha:1];
    self.progressSlider.maximumTrackTintColor = [UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1];
    [self.progressSlider setThumbImage:[UIImage imageNamed:@"iconfont-iconprogress-2"] forState:UIControlStateNormal];
    
    
    self.playBarView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.progressSlider.frame.origin.y+self.progressSlider.frame.size.height+WIDTH*0.035, WIDTH, WIDTH/6)];
    [self addSubview:self.playBarView];
    self.playBarView.userInteractionEnabled = YES;
    [_playBarView release];
    
    
    
    //播放列表
    self.listButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.listButton.frame = CGRectMake(0, 0, WIDTH/6, WIDTH/6);
    self.listButton.backgroundColor = [UIColor clearColor];
    [self.listButton setImage:[UIImage imageNamed:@"toolbar_playinglist_n_p@2x.png"] forState:UIControlStateNormal];
    [self.listButton setImage:[UIImage imageNamed:@"toolbar_playinglist_h_p@2x.png"] forState:UIControlStateHighlighted];
    [self.playBarView addSubview:self.listButton];
    
    
    //播放历史
    self.historyButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.historyButton.frame = CGRectMake(WIDTH-WIDTH/6, 0, WIDTH/6, WIDTH/6);
    self.historyButton.backgroundColor = [UIColor clearColor];
    [self.historyButton setImage:[UIImage imageNamed:@"toolbar_history_n_p@2x.png"] forState:UIControlStateNormal];
    [self.historyButton setImage:[UIImage imageNamed:@"toolbar_history_h_p@2x.png"] forState:UIControlStateHighlighted];
    [self.playBarView addSubview:self.historyButton];
    
    //上一首按钮
    self.upButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.upButton.frame = CGRectMake(self.listButton.frame.origin.x + self.listButton.frame.size.width + WIDTH*0.02, 0, WIDTH/6, WIDTH/6);
    self.upButton.backgroundColor = [UIColor clearColor];
    [self.upButton setImage:[UIImage imageNamed:@"toolbar_prev_n_p@2x.png"] forState:UIControlStateNormal ];
    [self.playBarView addSubview:self.upButton];
    
    //
    //    self.sliderView = [UIImageView alloc] initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)
    UIImageView *imageBg = [[UIImageView alloc] initWithFrame:CGRectMake(self.upButton.frame.origin.x + self.upButton.frame.size.width + WIDTH*0.05, -WIDTH*0.015, WIDTH/5, WIDTH/5)];
    imageBg.image = [UIImage imageNamed:@"toolbar_loading_n_p@2x.png"];
    imageBg.backgroundColor = [UIColor clearColor];
    [self.playBarView addSubview:imageBg];
    [imageBg release];
    
    //播放按钮
    self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.playButton.frame = CGRectMake(self.upButton.frame.origin.x + self.upButton.frame.size.width + WIDTH*0.05, 0, WIDTH/5, WIDTH/6);
    self.playButton.backgroundColor = [UIColor clearColor];
    [self.playButton setImage:[UIImage imageNamed:@"toolbar_play_n_p@2x.png"] forState:UIControlStateNormal];
    [self.playBarView addSubview:self.playButton];
    
    
    //下一首按钮
    self.nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.nextButton.frame = CGRectMake(self.playButton.frame.origin.x + self.playButton.frame.size.width + WIDTH*0.05, 0, WIDTH/6, WIDTH/6);
    self.nextButton.backgroundColor = [UIColor clearColor];
    [self.nextButton setImage:[UIImage imageNamed:@"toolbar_next_n_p@2x.png"] forState:UIControlStateNormal];
    [self.playBarView addSubview:self.nextButton];
    
    
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
